<%--
  Created by IntelliJ IDEA.
  User: hejiahao
  Date: 2021/12/18
  Time: 10:15
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="Util.JDBCUtils"%>
<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.PreparedStatement" %>
<%@ page import ="java.sql.*"%>
<%

    request.setCharacterEncoding("UTF-8");
    String goodscode = request.getParameter("goodscode");
    String sql = "delete from goods where goodscode = '"+ goodscode +"'";

    //注册加载一个Driver驱动
    try {
        Class.forName("com.mysql.cj.jdbc.Driver");
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    }
//获取数据库连接
    String jdbcURL = "jdbc:mysql://127.0.0.1:3306/goodslist?characterEncoding=UTF-8";
    Connection con = DriverManager.getConnection(jdbcURL,"root","123456");
//创建SQL命令对象
    Statement sm = con.createStatement();
//通过SQL命令对象执行SQL语句
    sm.execute(sql); // insert \ update \ delete
//释放所有对象
    if (sm != null){
        sm.close();
    }
    if (con != null){
        con.close();
    }
    response.sendRedirect("list.jsp");
%>
<html>
<head>
    <title>Delete</title>
</head>
<body>
</body>
</html>
